﻿using System.Data;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using Lucene.Linq.Demo.Properties;

namespace Lucene.Linq.Demo
{
    [Database(Name = "Northwind")]
    public partial class NorthwindDataContext : DataContext
    {
        #region Fields

        private static readonly MappingSource mappingSource = new AttributeMappingSource();

        #endregion

        #region Extensibility Method Definitions

        partial void OnCreated();
        partial void InsertCustomer(Customer instance);
        partial void UpdateCustomer(Customer instance);
        partial void DeleteCustomer(Customer instance);
        partial void InsertOrder(Order instance);
        partial void UpdateOrder(Order instance);
        partial void DeleteOrder(Order instance);

        #endregion

        #region Constructors

        static NorthwindDataContext()
        {
        }

        public NorthwindDataContext(string connection) :
            base(connection, mappingSource)
        {
            OnCreated();
        }

        public NorthwindDataContext(IDbConnection connection) :
            base(connection, mappingSource)
        {
            OnCreated();
        }

        public NorthwindDataContext(string connection, MappingSource mappingSource) :
            base(connection, mappingSource)
        {
            OnCreated();
        }

        public NorthwindDataContext(IDbConnection connection, MappingSource mappingSource) :
            base(connection, mappingSource)
        {
            OnCreated();
        }

        public NorthwindDataContext() :
            base(Settings.Default.NorthwindConnectionString, mappingSource)
        {
            OnCreated();
        }

        #endregion

        #region Properties

        public Table<Customer> Customers
        {
            get { return GetTable<Customer>(); }
        }


        public Table<Order> Orders
        {
            get { return GetTable<Order>(); }
        }

        #endregion
    }
}